package com.cloud.code.并发;

import org.junit.Test;

//@RunWith(SpringRunner.class)
//@SpringBootTest
public class ThreadTryLockCodeApplicationTests {

    private static int count = 0;

    @Test
    public void contextLoads() {
        System.out.println("hello world");
        for(int i = 0;i<3;i++){
            new Thread(() -> add()).start();
        }


    }

    public static void add(){
        for(int i= 0;i<100;i++){
            count ++;
            System.out.println(count+"ThreadName"+Thread.currentThread().getName());
            try {
                Thread.currentThread().sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


    }

}
